<script setup lang="ts">
import { ref } from 'vue'
import DxfParser from 'dxf-parser'
import threeDxfViewer from './three-dxf-gai/index.js'

const cadViewRef = ref()
const parser = new DxfParser()

const initDxf = async (string, width, height, fontUrl) => {
  var dxf = parser.parseSync(string)
  cadViewRef.value.innerHTML = ''
  await threeDxfViewer(dxf, cadViewRef.value, width, height, fontUrl)
}

defineExpose({
  initDxf
})
</script>

<template>
  <div ref="cadViewRef" class="cad-view"></div>
</template>

<style scoped>
.cad-view {
  display: inline-block !important;
  border: 1px solid rgb(0 0 0 / 0.2);
}
</style>
